#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QDebug>
#include <QCursor>
#include <QLabel>
#include <QFont>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QPushButton* button = new QPushButton(this);
    this->setWindowTitle("设置Title");
    button->setWindowTitle("按钮Title");
    button->setText("按钮");
    QIcon icon(":/1.png");
    this->setWindowIcon(icon);

    // 设置光标
//    this->setCursor(QCursor(Qt::WaitCursor));
//    ui->pushButton_plus->setCursor(QCursor(Qt::BlankCursor));
//    ui->pushButton_minus->setCursor(QCursor(Qt::SplitHCursor));

    // QPixmap 图片类
    QPixmap pixmap(":/2.png");
    QCursor cursor(pixmap,10,10);
    this->setCursor(cursor);

    QLabel* label = new QLabel(this);
    label->move(200,200);
    label->setText("这是一段文本");
//      QFont(const QString &family, int pointSize = -1, int weight = -1, bool italic = false);
    QFont font(QString("宋体"),25,50,true);
    font.setBold(true);
    font.setUnderline(true);
    label->setFont(font);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_plus_clicked()
{
    float opacity = this->windowOpacity();
    if(opacity >= 1.0 )
        return;
    qDebug() << opacity;
    opacity += 0.1;
    this->setWindowOpacity(opacity );
}

void Widget::on_pushButton_minus_clicked()
{
    double opacity = this->windowOpacity();
    if(opacity <= 0.0 )
        return;
    qDebug() << opacity;
    opacity -= 0.1;
    this->setWindowOpacity(opacity );
}
